using com.haopintui.util;
using System;
using System.Collections;
using System.Drawing;
using System.Windows.Forms;
namespace com.haopintui.ui
{
	public class CmsUI
	{
		public TabPage tabPageCms;
		public GroupBox groupBox40;
		public GroupBox groupBox41;
		public RichTextBox richTextBoxSts;
		public LinkLabel linkLabelGetPromot;
		public ComboBox comboBoxCmPPos;
		public ComboBox comboBoxCmPUnit;
		public ComboBox comboBoxCmsList;
		public RadioButton radioButtonCmMOth;
		public RadioButton radioButtonCmMApp;
		public RadioButton radioButtonCmMWeb;
		public Label label35;
		public Label label36;
		public Label label37;
		public Label label38;
		public TextBox textBoxAppCmsReson;
		public Button button_cms_click_apply;
		public Label label39;
		public Label label40;
		public Label label41;
		public Label label42;
		public Label label43;
		public Label label44;
		public TrackBar trackBarAlimama;
		public WebBrowser webBrowserQuanAlimama;
		public ContextMenuStrip contextMenuStripLoginPage;
		public Timer timer_kouling;
		public CmsUI(CmsForm cmsForm)
		{
			this.InitializeComponent(cmsForm);
		}
		private void InitializeComponent(CmsForm cmsForm)
		{
			this.tabPageCms = new TabPage();
			this.tabPageCms.SuspendLayout();
			cmsForm.tabControlMain.Controls.Add(this.tabPageCms);
			this.groupBox40 = new GroupBox();
			this.groupBox41 = new GroupBox();
			this.tabPageCms.Controls.Add(this.groupBox40);
			this.tabPageCms.Controls.Add(this.groupBox41);
			this.groupBox40.SuspendLayout();
			this.groupBox41.SuspendLayout();
			this.groupBox40.Location = new Point(16, 11);
			this.groupBox40.Name = "groupBox40";
			this.groupBox40.Size = new Size(433, 477);
			this.groupBox40.TabIndex = 54;
			this.groupBox40.TabStop = false;
			this.groupBox40.Text = "CMS转化设置";
			this.groupBox40.ResumeLayout(false);
			this.groupBox40.PerformLayout();
			this.groupBox41.Location = new Point(495, 11);
			this.groupBox41.Name = "groupBox41";
			this.groupBox41.Size = new Size(751, 477);
			this.groupBox41.TabIndex = 54;
			this.groupBox41.TabStop = false;
			this.groupBox41.Text = "执行状况";
			this.groupBox41.ResumeLayout(false);
			this.groupBox41.PerformLayout();
			this.richTextBoxSts = new RichTextBox();
			this.groupBox41.Controls.Add(this.richTextBoxSts);
			this.richTextBoxSts.HideSelection = false;
			this.richTextBoxSts.Location = new Point(5, 14);
			this.richTextBoxSts.Name = "richTextBoxSts";
			this.richTextBoxSts.ReadOnly = true;
			this.richTextBoxSts.Size = new Size(745, 458);
			this.richTextBoxSts.TabIndex = 2;
			this.richTextBoxSts.Text = "";
			this.linkLabelGetPromot = new LinkLabel();
			this.comboBoxCmPPos = new ComboBox();
			this.comboBoxCmPUnit = new ComboBox();
			this.comboBoxCmsList = new ComboBox();
			this.radioButtonCmMOth = new RadioButton();
			this.radioButtonCmMApp = new RadioButton();
			this.radioButtonCmMWeb = new RadioButton();
			this.label35 = new Label();
			this.label36 = new Label();
			this.label37 = new Label();
			this.label38 = new Label();
			this.label39 = new Label();
			this.label40 = new Label();
			this.label41 = new Label();
			this.label42 = new Label();
			this.label43 = new Label();
			this.label44 = new Label();
			this.textBoxAppCmsReson = new TextBox();
			this.button_cms_click_apply = new Button();
			this.trackBarAlimama = new TrackBar();
			this.webBrowserQuanAlimama = new WebBrowser();
			this.groupBox40.Controls.Add(this.linkLabelGetPromot);
			this.groupBox40.Controls.Add(this.comboBoxCmPPos);
			this.groupBox40.Controls.Add(this.comboBoxCmPUnit);
			this.groupBox40.Controls.Add(this.comboBoxCmsList);
			this.groupBox40.Controls.Add(this.radioButtonCmMOth);
			this.groupBox40.Controls.Add(this.radioButtonCmMApp);
			this.groupBox40.Controls.Add(this.radioButtonCmMWeb);
			this.groupBox40.Controls.Add(this.label35);
			this.groupBox40.Controls.Add(this.label36);
			this.groupBox40.Controls.Add(this.label37);
			this.groupBox40.Controls.Add(this.label38);
			this.groupBox40.Controls.Add(this.label39);
			this.groupBox40.Controls.Add(this.label40);
			this.groupBox40.Controls.Add(this.label41);
			this.groupBox40.Controls.Add(this.label42);
			this.groupBox40.Controls.Add(this.label43);
			this.groupBox40.Controls.Add(this.label44);
			this.groupBox40.Controls.Add(this.textBoxAppCmsReson);
			this.groupBox40.Controls.Add(this.button_cms_click_apply);
			this.groupBox40.Controls.Add(this.trackBarAlimama);
			this.groupBox40.Controls.Add(this.webBrowserQuanAlimama);
			this.linkLabelGetPromot.AutoSize = true;
			this.linkLabelGetPromot.LinkColor = Color.Red;
			this.linkLabelGetPromot.Location = new Point(164, 0);
			this.linkLabelGetPromot.Name = "linkLabelGetPromot";
			this.linkLabelGetPromot.Size = new Size(89, 12);
			this.linkLabelGetPromot.TabIndex = 17;
			this.linkLabelGetPromot.TabStop = true;
			this.linkLabelGetPromot.Text = "获取最新推广位";
			this.linkLabelGetPromot.LinkClicked += delegate(object sender, LinkLabelLinkClickedEventArgs e)
			{
				this.linkLabelGetPromot_LinkClicked(sender, cmsForm);
			};
			this.comboBoxCmPPos.DropDownStyle = ComboBoxStyle.DropDownList;
			this.comboBoxCmPPos.FormattingEnabled = true;
			this.comboBoxCmPPos.Location = new Point(81, 80);
			this.comboBoxCmPPos.Name = "comboBoxCmPPos";
			this.comboBoxCmPPos.Size = new Size(152, 20);
			this.comboBoxCmPPos.TabIndex = 16;
			this.comboBoxCmPUnit.DropDownStyle = ComboBoxStyle.DropDownList;
			this.comboBoxCmPUnit.FormattingEnabled = true;
			this.comboBoxCmPUnit.Location = new Point(81, 54);
			this.comboBoxCmPUnit.Name = "comboBoxCmPUnit";
			this.comboBoxCmPUnit.Size = new Size(152, 20);
			this.comboBoxCmPUnit.TabIndex = 15;
			this.comboBoxCmPUnit.SelectedIndexChanged += delegate(object o, EventArgs e)
			{
				this.comboBoxCmPUnit_SelectedIndexChanged(o, cmsForm);
			};
			this.comboBoxCmsList.DropDownStyle = ComboBoxStyle.DropDownList;
			this.comboBoxCmsList.FormattingEnabled = true;
			this.comboBoxCmsList.Location = new Point(81, 114);
			this.comboBoxCmsList.Name = "comboBoxCmsList";
			this.comboBoxCmsList.Size = new Size(152, 20);
			this.comboBoxCmsList.TabIndex = 15;
			this.textBoxAppCmsReson.Location = new Point(9, 178);
			this.textBoxAppCmsReson.Name = "textBoxAppCmsReson";
			this.textBoxAppCmsReson.Size = new Size(387, 85);
			this.textBoxAppCmsReson.TabIndex = 17;
			this.textBoxAppCmsReson.Multiline = true;
			this.radioButtonCmMOth.AutoSize = true;
			this.radioButtonCmMOth.Location = new Point(162, 23);
			this.radioButtonCmMOth.Name = "radioButtonCmMOth";
			this.radioButtonCmMOth.Size = new Size(71, 16);
			this.radioButtonCmMOth.TabIndex = 14;
			this.radioButtonCmMOth.TabStop = true;
			this.radioButtonCmMOth.Text = "导购推广";
			this.radioButtonCmMOth.UseVisualStyleBackColor = true;
			this.radioButtonCmMOth.Enabled = false;
			this.radioButtonCmMApp.AutoSize = true;
			this.radioButtonCmMApp.Location = new Point(89, 25);
			this.radioButtonCmMApp.Name = "radioButtonCmMApp";
			this.radioButtonCmMApp.Size = new Size(65, 16);
			this.radioButtonCmMApp.TabIndex = 13;
			this.radioButtonCmMApp.TabStop = true;
			this.radioButtonCmMApp.Text = "APP推广";
			this.radioButtonCmMApp.UseVisualStyleBackColor = true;
			this.radioButtonCmMApp.Enabled = false;
			this.radioButtonCmMWeb.AutoSize = true;
			this.radioButtonCmMWeb.Location = new Point(12, 25);
			this.radioButtonCmMWeb.Name = "radioButtonCmMWeb";
			this.radioButtonCmMWeb.Size = new Size(71, 16);
			this.radioButtonCmMWeb.TabIndex = 12;
			this.radioButtonCmMWeb.TabStop = true;
			this.radioButtonCmMWeb.Text = "网站推广";
			this.radioButtonCmMWeb.UseVisualStyleBackColor = true;
			this.radioButtonCmMWeb.Checked = true;
			this.radioButtonCmMWeb.Enabled = false;
			this.label35.AutoSize = true;
			this.label35.Location = new Point(10, 83);
			this.label35.Name = "label35";
			this.label35.Size = new Size(53, 12);
			this.label35.TabIndex = 10;
			this.label35.Text = "推广位：";
			this.label36.AutoSize = true;
			this.label36.Location = new Point(9, 57);
			this.label36.Name = "label36";
			this.label36.Size = new Size(65, 12);
			this.label36.TabIndex = 6;
			this.label36.Text = "推广单元：";
			this.label37.AutoSize = true;
			this.label37.Location = new Point(9, 114);
			this.label37.Name = "label37";
			this.label37.Size = new Size(65, 12);
			this.label37.TabIndex = 6;
			this.label37.Text = "CMS选择：";
			this.label38.AutoSize = true;
			this.label38.Location = new Point(9, 146);
			this.label38.Name = "label38";
			this.label38.Size = new Size(65, 12);
			this.label38.TabIndex = 6;
			this.label38.Text = "计划申请理由：";
			this.label39.AutoSize = true;
			this.label39.Location = new Point(10, 339);
			this.label39.Name = "label39";
			this.label39.Size = new Size(53, 12);
			this.label39.TabIndex = 10;
			this.label39.Text = "";
			this.label40.AutoSize = true;
			this.label40.Location = new Point(161, 339);
			this.label40.Name = "label39";
			this.label40.Size = new Size(53, 12);
			this.label40.TabIndex = 10;
			this.label40.Text = "";
			this.button_cms_click_apply.Location = new Point(92, 290);
			this.button_cms_click_apply.Name = "button_cms_click_apply";
			this.button_cms_click_apply.Size = new Size(141, 27);
			this.button_cms_click_apply.TabIndex = 29;
			this.button_cms_click_apply.Text = "开始自动批量转化";
			this.button_cms_click_apply.UseVisualStyleBackColor = true;
			this.button_cms_click_apply.BackColor = Color.Green;
			this.button_cms_click_apply.ForeColor = Color.White;
			this.button_cms_click_apply.Click += delegate(object o, EventArgs e)
			{
				this.button_cms_click_apply_click(o, cmsForm);
			};
			this.tabPageCms.Location = new Point(4, 29);
			this.tabPageCms.Name = "tabPageCms";
			this.tabPageCms.Padding = new Padding(3);
			this.tabPageCms.Size = new Size(1253, 531);
			this.tabPageCms.TabIndex = 0;
			this.tabPageCms.Text = "CMS转化链接";
			this.tabPageCms.UseVisualStyleBackColor = true;
			this.tabPageCms.ResumeLayout(false);
			this.label43.AutoSize = true;
			this.label43.Location = new Point(9, 370);
			this.label43.Name = "label43";
			this.label43.Size = new Size(53, 12);
			this.label43.TabIndex = 10;
			this.label43.Text = "阿里妈妈请求间隔（秒）：" + cmsForm.appBean.alimama_request_url_time;
			this.label44.AutoSize = true;
			this.label44.Location = new Point(9, 434);
			this.label44.Name = "label43";
			this.label44.Size = new Size(53, 12);
			this.label44.TabIndex = 10;
			this.label44.Text = "建议将间隔时间设置为大于1秒，防止被阿里限制";
			this.trackBarAlimama.Location = new Point(9, 402);
			this.trackBarAlimama.Minimum = 0;
			this.trackBarAlimama.Maximum = 10;
			this.trackBarAlimama.Name = "trackBarAlimama";
			this.trackBarAlimama.Size = new Size(249, 45);
			this.trackBarAlimama.BackColor = Color.White;
			this.trackBarAlimama.TabIndex = 1;
			this.trackBarAlimama.Value = cmsForm.appBean.alimama_request_url_time;
			this.trackBarAlimama.ValueChanged += delegate(object o, EventArgs e)
			{
				this.change_alimama_requset_time(o, cmsForm);
			};
			this.contextMenuStripLoginPage = new ContextMenuStrip(cmsForm.icontainer);
			this.webBrowserQuanAlimama.ContextMenuStrip = this.contextMenuStripLoginPage;
			this.webBrowserQuanAlimama.Location = new Point(8, 12);
			this.webBrowserQuanAlimama.MinimumSize = new Size(20, 20);
			this.webBrowserQuanAlimama.Name = "webBrowserLoginAlimama";
			this.webBrowserQuanAlimama.Size = new Size(1, 1);
			this.webBrowserQuanAlimama.TabIndex = 29;
			this.contextMenuStripLoginPage.Name = "contextMenuStripLoginPage";
			this.contextMenuStripLoginPage.Size = new Size(61, 4);
			this.webBrowserQuanAlimama.ScriptErrorsSuppressed = true;
			this.webBrowserQuanAlimama.IsWebBrowserContextMenuEnabled = false;
			this.timer_kouling = new Timer();
			this.timer_kouling.Enabled = true;
			this.timer_kouling.Interval = 500;
			this.timer_kouling.Tick += delegate(object oo, EventArgs ee)
			{
				this.timer_0_Tick_1(oo, cmsForm);
			};
			this.timer_kouling.Start();
		}
		public void change_alimama_requset_time(object sender, object formOfSender)
		{
			CmsForm cmsForm = (CmsForm)formOfSender;
			this.label43.Text = "阿里妈妈请求间隔（秒）：" + this.trackBarAlimama.Value;
			cmsForm.appBean.alimama_request_url_time = this.trackBarAlimama.Value;
		}
		public void comboBoxCmPUnit_SelectedIndexChanged(object sender, object formOfSender)
		{
			CmsForm cmsForm = (CmsForm)formOfSender;
			CmsUtil.comboBoxBrdgPUnit_SelectedIndexChanged(cmsForm);
		}
		public void button_cms_click_apply_click(object sender, object formOfSender)
		{
			CmsForm cmsForm = (CmsForm)formOfSender;
			if (!cmsForm.appBean.apply_taoke_url_status)
			{
				CmsUtil.cms_apply_taoke_url(cmsForm, 1);
				return;
			}
			CmsUtil.cms_apply_taoke_url(cmsForm, 0);
		}
		private void linkLabelGetPromot_LinkClicked(object sender, object formOfSender)
		{
			CmsForm cmsForm = (CmsForm)formOfSender;
			try
			{
				if (!AlimamaUtil.check_login(cmsForm.appBean.taoke_cookie))
				{
					LogUtil.log_call(cmsForm, "登录以后再查看和修改PID！");
					cmsForm.appBean.alimama_login_status = false;
					AlimamaLogin.login(cmsForm);
				}
				else
				{
					LogUtil.log_call(cmsForm, "获取CMS广告位信息！");
					AlimamaAdUtil.updAliPid(cmsForm);
				}
			}
			catch (Exception ex)
			{
				LogUtil.log_call(cmsForm, "[linkLabelGetPromot_LinkClicked]出错：" + ex.ToString());
			}
		}
		private void timer_0_Tick_1(object sender, object formOfSender)
		{
			CmsForm cmsForm = (CmsForm)formOfSender;
			if (cmsForm.appBean.apply_taoke_url_status)
			{
				try
				{
					HtmlElement elementById = cmsForm.cmsUI.webBrowserQuanAlimama.Document.GetElementById("mx_8");
					if (elementById != null && elementById.GetAttribute("className").Contains("share-kl"))
					{
						IEnumerator enumerator = elementById.GetElementsByTagName("div").GetEnumerator();
						while (enumerator.MoveNext())
						{
							HtmlElement htmlElement = (HtmlElement)enumerator.Current;
							string attribute = htmlElement.GetAttribute("className");
							if (attribute != null && attribute.Contains("share-con"))
							{
								htmlElement.InvokeMember("click");
							}
						}
					}
				}
				catch (Exception)
				{
				}
				try
				{
					HtmlElement elementById2 = cmsForm.cmsUI.webBrowserQuanAlimama.Document.GetElementById("atomdlg_11");
					if (elementById2 != null && elementById2.GetAttribute("className").Contains("atom-dialog-wrap"))
					{
						IEnumerator enumerator2 = elementById2.GetElementsByTagName("div").GetEnumerator();
						while (enumerator2.MoveNext())
						{
							HtmlElement htmlElement2 = (HtmlElement)enumerator2.Current;
							string attribute2 = htmlElement2.GetAttribute("className");
							if (attribute2 != null && attribute2.Contains("kouling-content"))
							{
								string taokouling = StringUtil.subString(htmlElement2.InnerHtml, 0, "\ud83d\udc49手淘\ud83d\udc48", "】");
								cmsForm.appBean.taokouling = taokouling;
							}
						}
					}
				}
				catch (Exception)
				{
				}
			}
		}
	}
}
